package game.zqll.systems;

import com.artemis.Aspect;
import com.artemis.systems.IteratingSystem;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import game.zqll.components.BorderComp;
import game.zqll.components.PosComp;
import game.zqll.components.SizeComp;

public class BorderRenderSystem extends IteratingSystem {

    private CameraSystem cameraSystem;
    public final ShapeRenderer shapeRenderer;

    public BorderRenderSystem() {
        super(Aspect.all(BorderComp.class, PosComp.class, SizeComp.class));
        shapeRenderer = new ShapeRenderer();
    }

    @Override
    protected void process(int entityId) {
        BorderComp borderComp = Mappers.border.get(entityId);
        shapeRenderer.setProjectionMatrix(cameraSystem.getCamera().combined);
        shapeRenderer.begin(borderComp.type);
        shapeRenderer.setColor(borderComp.color);
        PosComp posComp = Mappers.pos.get(entityId);
        SizeComp sizeComp = Mappers.size.get(entityId);
        shapeRenderer.rect(posComp.x,  posComp.y, sizeComp.width, sizeComp.height);
        shapeRenderer.end();
    }
}
